package com.yellowpage.bigdata.action;
  
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;

import com.yellowpage.tool.Excelexport;
import com.yellowpage.white.common.Configuration;
import com.yellowpage.white.common.Constants;
import com.yellowpage.white.struts.BaseAction;
import com.yellowpage.white.struts.Module;
import com.yellowpage.white.struts.OperationType;
import com.yellowpage.white.util.Util4Java;
import com.yellowpage.bigdata.data.O2oLogSumDay;
import com.yellowpage.bigdata.service.O2oLogSumDayService;
import org.apache.poi.hssf.usermodel.*;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletResponse;

public class O2oLogSumDayAction extends BaseAction {

  
 
	

	private O2oLogSumDay o2oLogSumDay;
	private O2oLogSumDayService o2oLogSumDayService;
	
	private String selectedId;
	private String query_logDate;
	private String query_o2o_id;
	private String query_logDate_end;
	private List<Map> resultList = new ArrayList<Map>();
	private Map O2oIdMap = new HashMap();
 	
 
		
	public void prepare() {
		super.prepare();
		// 加载O2OID
		O2oIdMap = o2oLogSumDayService.getO2oIdMap();
		if (this.selectedId != null && !this.selectedId.equals("")) {
			this.o2oLogSumDay = o2oLogSumDayService.getO2oLogSumDay(Long.parseLong(selectedId));
		}
	}
	
	public String queryByPage() {		
		initPageRender();
		
		Map<String,String> queryMap = new HashMap<String,String>();	
	    	    queryMap.put("o2oId", query_o2o_id);
	    	    queryMap.put("logDate", query_logDate);
	    		queryMap.put("query_logDate_end", query_logDate_end);
	    	    	
		resultList = o2oLogSumDayService.queryO2oLogSumDayByPage(queryMap, pageRender);
		
		setPageRenderToRequest();

		return "query";
	}


	public void exportExcel()

	{
		Map queryMap = new HashMap();


		queryMap.put("o2oId", query_o2o_id);
		queryMap.put("logDate", query_logDate);
		queryMap.put("query_logDate_end", query_logDate_end);




		//给出全量值
		resultList = o2oLogSumDayService.queryO2oLogSumDayByPage(queryMap);
		LinkedHashMap<String,String> namemap= new LinkedHashMap<String,String>();



		//给出中文名称
		namemap.put("DAY_ID","日期");
		namemap.put("O2O_ID","O2O_ID");
		namemap.put("O2O_NAME","O2O名称");
		namemap.put("YES_UV","UV（昨日）");
		namemap.put("UV","UV（今日）");
		namemap.put("YES_PV","PV（昨日）");
		namemap.put("PV","PV（今日）");
		namemap.put("TOTAL_UV","累计Uv");
		namemap.put("TOTAL_PV","累计Pv");

		Excelexport.exportExcel(resultList, this.getClass().getName(), namemap);


	}




	public O2oLogSumDay getO2oLogSumDay() {
		return o2oLogSumDay;
	}

	public void setO2oLogSumDay(O2oLogSumDay o2oLogSumDay) {
		this.o2oLogSumDay = o2oLogSumDay;
	}

	public O2oLogSumDayService getO2oLogSumDayService() {
		return o2oLogSumDayService;
	}

	public void setO2oLogSumDayService(O2oLogSumDayService o2oLogSumDayService) {
		this.o2oLogSumDayService = o2oLogSumDayService;
	}

	public String getSelectedId() {
		return selectedId;
	}

	public void setSelectedId(String selectedId) {
		this.selectedId = selectedId;
	}

	public String getQuery_logDate() {
		return query_logDate;
	}

	public void setQuery_logDate(String query_logDate) {
		this.query_logDate = query_logDate;
	}

	public String getQuery_o2o_id() {
		return query_o2o_id;
	}

	public void setQuery_o2o_id(String query_o2o_id) {
		this.query_o2o_id = query_o2o_id;
	}

	public String getQuery_logDate_end() {
		return query_logDate_end;
	}

	public void setQuery_logDate_end(String query_logDate_end) {
		this.query_logDate_end = query_logDate_end;
	}

	public List<Map> getResultList() {
		return resultList;
	}

	public void setResultList(List<Map> resultList) {
		this.resultList = resultList;
	}

	public Map getO2oIdMap() {
		return O2oIdMap;
	}

	public void setO2oIdMap(Map o2oIdMap) {
		O2oIdMap = o2oIdMap;
	}
 
    
	
}
